home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / ici / ici.cpi / int.c < prev    next >
C/C++ Source or Header  |  1994-10-27  |  859b  |  62 lines

  1. #include "int.h"
  2.  
  3. STATIC long
  4. mark_int(o)
  5. object_t    *o;
  6. {
  7.     o->o_flags |= O_MARK;
  8.     return sizeof(int_t);
  9. }
  10.  
  11. STATIC int
  12. cmp_int(i1, i2)
  13. int_t    *i1;
  14. int_t    *i2;
  15. {
  16.     return i1->i_value != i2->i_value;
  17. }
  18.  
  19. STATIC long
  20. hash_int(i)
  21. int_t    *i;
  22. {
  23.     return i->i_value * 7;
  24. }
  25.  
  26. int_t *
  27. new_int(v)
  28. long    v;
  29. {
  30.     register int_t    *i;
  31.  
  32.     /*
  33.      * There is an in-line copy of this near the end of binop.h
  34.      */
  35.     if ((i = atom_int(v)) != NULL)
  36.     {
  37.     got(i);
  38.     return i;
  39.     }
  40.     if ((i = talloc(int_t)) == NULL)
  41.     return NULL;
  42.     objof(i)->o_type = &int_type;
  43.     objof(i)->o_tcode = TC_INT;
  44.     objof(i)->o_flags = 0;
  45.     objof(i)->o_nrefs = 1;
  46.     rego(i);
  47.     i->i_value = v;
  48.     return intof(atom(objof(i), 1));
  49. }
  50.  
  51. type_t    int_type =
  52. {
  53.     mark_int,
  54.     free_simple,
  55.     hash_int,
  56.     cmp_int,
  57.     copy_simple,
  58.     assign_simple,
  59.     fetch_simple,
  60.     "int"
  61. };
  62.